home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 83win / data1.cab / DLL_Toolkit / Source / HTBListBox / EditDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  2.2 KB  |  114 lines

  1. // EditDlg.cpp : implementation file
  2. // Sven Henze, Tech Soft GmbH 1999
  3.  
  4. #include "stdafx.h"
  5. #include "listbox.h"
  6. #include "EditDlg.h"
  7. #include "ListboxDlg.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CEditDlg dialog
  18.  
  19.  
  20. CEditDlg::CEditDlg(CWnd* pParent /*=NULL*/)
  21.     : CDialog(CEditDlg::IDD, pParent)
  22. {
  23.     //{{AFX_DATA_INIT(CEditDlg)
  24.         // NOTE: the ClassWizard will add member initialization here
  25.     //}}AFX_DATA_INIT
  26.  
  27.     m_peParent = pParent;
  28.     m_neID = CEditDlg::IDD;
  29.  
  30. }
  31.  
  32.  
  33. void CEditDlg::DoDataExchange(CDataExchange* pDX)
  34. {
  35.     CDialog::DoDataExchange(pDX);
  36.     //{{AFX_DATA_MAP(CEditDlg)
  37.         // NOTE: the ClassWizard will add DDX and DDV calls here
  38.     //}}AFX_DATA_MAP
  39. }
  40.  
  41.  
  42. BEGIN_MESSAGE_MAP(CEditDlg, CDialog)
  43.     //{{AFX_MSG_MAP(CEditDlg)
  44.     //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CEditDlg message handlers
  49.  
  50. BOOL CEditDlg::Create()
  51. {
  52.     return CDialog::Create(m_neID, m_peParent);
  53.  
  54. }    // Create
  55.  
  56.  
  57. void CEditDlg::CloseDialog()
  58. {
  59.     ((ListboxDlg*)m_peParent)->EditBoxDone();
  60.     DestroyWindow();
  61.  
  62. }    // DestroyWindow
  63.  
  64.  
  65. // OK button was pressed
  66. void CEditDlg::OnOK() 
  67. {
  68.     int cnt, i;
  69.     CListBox* pList;
  70.  
  71.     // get pointer to ListBox window
  72.     if (SingleSelection)
  73.     {
  74.         g_pList = (CListBox*) (m_peParent->GetDlgItem(IDC_LIST2));
  75.     }
  76.     else    
  77.     {
  78.         pList = (CListBox*) (m_peParent->GetDlgItem(IDC_LIST1));
  79.     }
  80.  
  81.  
  82.     CEdit* pEdit = (CEdit*) GetDlgItem(IDC_EDIT1);   // pointer to edit resource
  83.     CString str;
  84.  
  85.     pEdit->GetWindowText(str);               // get text from edit window
  86.  
  87.     if (!str.IsEmpty())                       // do not insert/edit NULL strings
  88.     {
  89.         cnt = Getcount();                    // number of items in listbox
  90.  
  91.         i=0;
  92.         while (Getsel(i+1)==0)
  93.         {
  94.             i++;
  95.         }
  96.  
  97.         // variable 'j' now contains the selected item. Add the item on this position now !
  98.         pList->DeleteString( i );
  99.         pList->InsertString( i, str );
  100.  
  101.     }    // not IsEmpty
  102.  
  103.     CloseDialog();
  104.  
  105. }    // OnOK
  106.  
  107.  
  108. // Cancel was pressed
  109. void CEditDlg::OnCancel() 
  110. {
  111.    CloseDialog();
  112.  
  113. }    // OnCancel
  114.